package com.qm.console.controller.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;

@JsonInclude
@ApiModel(value = "响应数据")
public class BaseDO<T> implements Serializable {

    private static final long serialVersionUID = -4185151304730685914L;

    @ApiModelProperty(value="状态码")
    private int status;
    @ApiModelProperty(value="响应信息")
    private String message;
    @ApiModelProperty(value="响应内容")
    private T data;
    
    private Object error;

    public BaseDO(){}
    public BaseDO(int status, String message) {
        this(status, message, null);
    }

    public BaseDO(int status, T data) {
        this(status, "", data);
    }

    public BaseDO(T data) {
        this(ResultEnum.SUCCESS.getState(), ResultEnum.SUCCESS.getMsg(), data);
    }

    public BaseDO(ResultEnum resultEnum) {
        this(resultEnum.getState(), resultEnum.getMsg(), null);
    }

    public BaseDO(ResultEnum resultEnum, T data) {
        this(resultEnum.getState(), resultEnum.getMsg(), data);
    }

    public BaseDO(int status, String message, T data) {
        this.status = status;
        this.message = message;
        this.data = data;
    }

    public T getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = (T) data;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getMessage() {
        return message;
    }

    public Object getError() {
        return error;
    }

    public void setError(Object error) {
        this.error = error;
    }

    @Override
    public String toString() {
        return "BaseDO [status=" + status + ", data=" + data + ", message=" + message + "]";
    }

}
